package test.org.orbis.sandbox;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.junit.Test;
import org.orbis.term.Term;
import org.orbis.term.TermList;
import org.orbis.term.chopper.Chopper;

public class SandBox{
	@Test
	public void sandbox(){
		Chopper chopper;
		String impl = "org.orbis.term.chopper.impl.";
		String gosenName = "GosenChopper";
		String unigramName = "UnigramChopper";
		
		try{
			Class<Chopper> cls = (Class<Chopper>)Class.forName(impl + gosenName);
			Constructor<Chopper> constructor = cls.getConstructor();
			chopper = constructor.newInstance();
			TermList terms = chopper.chop("にわにはにわにわとりがいる");
			for(Term term: terms){
				System.out.println("Term: " + term.str());
			}
			
			System.out.println("-----");
			
			cls = (Class<Chopper>)Class.forName(impl + unigramName);
			constructor = cls.getConstructor();
			chopper = constructor.newInstance();
			terms = chopper.chop("にわにはにわにわとりがいる");
			for(Term term: terms){
				System.out.println("Term: " + term.str());
			}
		}catch(ClassNotFoundException e){
			e.printStackTrace();
		}catch(SecurityException e){
			e.printStackTrace();
		}catch(NoSuchMethodException e){
			e.printStackTrace();
		}catch(IllegalArgumentException e){
			e.printStackTrace();
		}catch(InstantiationException e){
			e.printStackTrace();
		}catch(IllegalAccessException e){
			e.printStackTrace();
		}catch(InvocationTargetException e){
			e.printStackTrace();
		}
	}
}
